<?php

namespace app\controller;

use app\BaseController;
use think\facade\Db; // 确保正确引入 Db facade

class Demo extends BaseController
{
    public function hello($name = 'ThinkPHP8')
    {
        return 'hello,' . $name;
    }

    public function index()
    {
        return '<style>*{ padding: 0; margin: 0; }</style><iframe src="https://www.thinkphp.cn/welcome?version=' . \think\facade\App::version() . '" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>';
    }

    public function test($name = 'ThinkPHP8') // 添加默认值
    {
        return 'it\'s for ' . $name;
    }

    public function pathact()
{
    $path = $this->request->pathinfo();
    $action = $this->request->action();
    return 'the path: ' . $path . ' the action: ' . $action;
}

    public function dbpro()
    {
        $data = Db::table('tp_access')->where('id', 1)->find(); // 使用 Db facade
        return json_encode($data);
    }
}